!--------------------------------------------------------------------

subroutine init_buffers_lbc(init)

  use node_mod, only: &
       mynum,         & !INTENT(IN)
       f_ndmd_size,   & !INTENT(OUT)
       node_buffs,    & !INTENT(INOUT)
       nmachs,        & !INTENT(IN)
       nbuff_feed,    & !INTENT(IN)
       node_buffs_st    !INTENT(OUT)

  use mem_grid, only:    &
       nnzp, nnxp, nnyp, & !INTENT(IN)
       ibnd, jbnd          !INTENT(IN)

  use var_tables, only: &
       num_var,         & !INTENT(IN)
       vtab_r             !INTENT(IN)

  implicit none
  integer, intent(in) :: init
  integer             :: nm, nv, npvar
  !____________________________________________
  !
  !    Allocate long time step send and receive buffers

  ! Checking the size of real and integer packages, and setting up the 
  ! largest as standard, so nothing is lost...
  call parf_pack_max_size(1, f_ndmd_size)

  if(init /= 1) then
     do nm=1,nmachs
        if (associated(node_buffs(nm)%lbc_send_buff) )    &
            deallocate(node_buffs(nm)%lbc_send_buff)
        if (associated(node_buffs(nm)%lbc_recv_buff) )    &
            deallocate(node_buffs(nm)%lbc_recv_buff)
        if (associated(node_buffs_st(nm)%lbc_send_buff) ) &
            deallocate(node_buffs_st(nm)%lbc_send_buff)
        if (associated(node_buffs_st(nm)%lbc_recv_buff) ) &
            deallocate(node_buffs_st(nm)%lbc_recv_buff)
     end do
  end if

  do nm=1,nmachs
     node_buffs(nm)%nsend = max(node_buffs(nm)%nsend ,nbuff_feed)
     node_buffs(nm)%nrecv = max(node_buffs(nm)%nrecv ,nbuff_feed)
     node_buffs_st(nm)%nsend = node_buffs(nm)%nsend
     node_buffs_st(nm)%nrecv = node_buffs(nm)%nrecv
  
   if (node_buffs(nm)%nsend > 0) &
       allocate(node_buffs(nm)%lbc_send_buff(node_buffs(nm)%nsend*f_ndmd_size))
   if (node_buffs(nm)%nrecv > 0) &
       allocate(node_buffs(nm)%lbc_recv_buff(node_buffs(nm)%nrecv*f_ndmd_size))
   if (node_buffs_st(nm)%nsend > 0) &
       allocate(node_buffs_st(nm)%lbc_send_buff(node_buffs_st(nm)%nsend*f_ndmd_size))
   if (node_buffs_st(nm)%nrecv > 0) &
       allocate(node_buffs_st(nm)%lbc_recv_buff(node_buffs_st(nm)%nrecv*f_ndmd_size))
  end do

  ! If using cyclic boundary conditions, initialize parallel communication
  ! for them
  !  Find number of lbc variables to be communicated.
  npvar=0
  do nv = 1,num_var(1)
     if(vtab_r(nv,1)%impt1==1 ) then
        npvar=npvar+1
     endif
  enddo

  if (ibnd==4 .or. jbnd==4) then
     call node_cycinit(nnzp(1),nnxp(1),nnyp(1),npvar,nmachs,ibnd,jbnd,mynum)
  endif

  
end subroutine init_buffers_lbc

!--------------------------------------------------------------------
